<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>i2c: C:/Users/Jon/Downloads/OOP/index.php Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">i2c
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">C:/Users/Jon/Downloads/OOP/index.php</div>  </div>
</div>
<div class="contents">
<a href="index_8php.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
<a name="l00002"></a>00002 session_start();
<a name="l00003"></a><a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">00003</a> <a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a> = <span class="stringliteral">&#39;&#39;</span>;
<a name="l00004"></a><a class="code" href="index_8php.html#a55583faec9072fb2917b0c3645b11280">00004</a> <a class="code" href="admin_2index_8php.html#a55583faec9072fb2917b0c3645b11280">$self</a> = $_SERVER[<span class="stringliteral">&#39;PHP_SELF&#39;</span>];
<a name="l00005"></a><a class="code" href="index_8php.html#a831ba15ebf5bad83fc6abbb9c631c0e4">00005</a> <span class="keywordflow">if</span> (isset($_POST[<span class="stringliteral">&#39;login&#39;</span>])) {
<a name="l00006"></a>00006    <span class="comment">//user is trying to login</span>
<a name="l00007"></a>00007    <a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a> = <a class="code" href="index_8php.html#a61961bfa06c5bf6f45ee402d0696417d">checkUsernamePassword</a>();
<a name="l00008"></a>00008    <span class="keywordflow">if</span> (!<a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a>) {
<a name="l00009"></a>00009       include <span class="stringliteral">&#39;db-control/dbCredentials.php&#39;</span>;
<a name="l00010"></a>00010       include <span class="stringliteral">&#39;model/Credentials.php&#39;</span>;
<a name="l00011"></a>00011       <span class="comment">//attempt to log in</span>
<a name="l00012"></a>00012       $cred = <span class="keyword">new</span> <a class="code" href="class_credentials.html">Credentials</a>($_POST[<span class="stringliteral">&#39;username&#39;</span>], $_POST[<span class="stringliteral">&#39;pw&#39;</span>]);
<a name="l00013"></a>00013           <span class="comment">//$cred = new Credentials(&quot;&quot;,&quot;&quot;);</span>
<a name="l00014"></a>00014       <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = <a class="code" href="classdb_credentials.html#a44c36f6a1a96d52316d09c7de866123d">dbCredentials::login</a>($cred);
<a name="l00015"></a>00015 
<a name="l00016"></a>00016       <span class="keywordflow">if</span> (!<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>) {
<a name="l00017"></a>00017          <a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a> = <span class="stringliteral">&quot;Username or password is incorrect...&quot;</span>;
<a name="l00018"></a>00018       } 
<a name="l00019"></a>00019           <span class="keywordflow">else</span> {
<a name="l00020"></a>00020          <span class="comment">//user is logged in</span>
<a name="l00021"></a>00021          $fname = <a class="code" href="logout_8php.html#aa3f93905a0a94ad29ddd47d9e5638098">$_SESSION</a>[<span class="stringliteral">&#39;fname&#39;</span>];
<a name="l00022"></a>00022          echo <span class="stringliteral">&quot;Welcome, $fname! Log in successful!&quot;</span>;
<a name="l00023"></a>00023          <a class="code" href="index_8php.html#a74b79a6d5481c21eb854bced198efc64">forwardToURL</a>(<a class="code" href="logout_8php.html#aa3f93905a0a94ad29ddd47d9e5638098">$_SESSION</a>[<span class="stringliteral">&#39;permissionLevel&#39;</span>]);
<a name="l00024"></a>00024       }
<a name="l00025"></a>00025    }
<a name="l00026"></a>00026 }
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 ?&gt;
<a name="l00031"></a>00031 &lt;html&gt;
<a name="l00032"></a>00032    &lt;head&gt;
<a name="l00033"></a>00033       &lt;title&gt;UNHM Internships&lt;/title&gt;
<a name="l00034"></a>00034       &lt;link rel=<span class="stringliteral">&quot;stylesheet&quot;</span> type=<span class="stringliteral">&quot;text/css&quot;</span> href=<span class="stringliteral">&quot;css/style.css&quot;</span> /&gt;
<a name="l00035"></a>00035    &lt;/head&gt;
<a name="l00036"></a>00036    &lt;body&gt;
<a name="l00037"></a>00037       &lt;table width=<span class="stringliteral">&quot;100%&quot;</span>&gt;&lt;div align=<span class="stringliteral">&quot;left&quot;</span>&gt;
<a name="l00038"></a>00038             &lt;tr&gt;&lt;td rowspan=<span class="stringliteral">&quot;5&quot;</span>&gt;&lt;img src=<span class="stringliteral">&quot;img/unhmlogo.png&quot;</span> width=<span class="stringliteral">&quot;200px&quot;</span> height=<span class="stringliteral">&quot;120px&quot;</span> /&gt;&lt;/td&gt;&lt;/tr&gt;
<a name="l00039"></a>00039             &lt;tr&gt;&lt;td width=<span class="stringliteral">&quot;80%&quot;</span>&gt;&lt;h3&gt;Login&lt;/h3&gt;&lt;br /&gt;&lt;/td&gt;&lt;td align=<span class="stringliteral">&quot;right&quot;</span> width=<span class="stringliteral">&quot;20%&quot;</span> valign=<span class="stringliteral">&quot;top&quot;</span>&gt;&lt;/td&gt;&lt;td align=<span class="stringliteral">&quot;left&quot;</span> valign=<span class="stringliteral">&quot;top&quot;</span>&gt;&lt;a href=<span class="stringliteral">&quot;help.php&quot;</span> title=<span class="stringliteral">&quot;View the help documentation&quot;</span>&gt;?&lt;/a&gt;&lt;/tr&gt;
<a name="l00040"></a>00040             &lt;tr&gt;&lt;td&gt;&lt;p&gt;Please enter your username and password:&lt;/p&gt;&lt;hr /&gt;&lt;/td&gt;&lt;/tr&gt;
<a name="l00041"></a>00041       &lt;/table&gt;&lt;br /&gt;&lt;br /&gt;
<a name="l00042"></a>00042       &lt;form action =<span class="stringliteral">&quot;&lt;?php echo $self; ?&gt;&quot;</span> method =<span class="stringliteral">&quot;post&quot;</span>&gt;
<a name="l00043"></a>00043          &lt;div align=<span class="stringliteral">&quot;center&quot;</span>&gt;
<a name="l00044"></a>00044             &lt;table width=<span class="stringliteral">&quot;500px&quot;</span>&gt;
<a name="l00045"></a>00045                &lt;tr&gt;&lt;td colspan=<span class="stringliteral">&quot;2&quot;</span>&gt;&lt;?php echo <span class="stringliteral">&quot;&lt;p class=&#39;error&#39;&gt;$error&lt;/p&gt;&quot;</span>; ?&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
<a name="l00046"></a>00046                &lt;tr&gt;&lt;td align=<span class="stringliteral">&quot;right&quot;</span>&gt;Username:&lt;/td&gt;&lt;td&gt;&lt;input type=<span class="stringliteral">&quot;text&quot;</span> name=<span class="stringliteral">&quot;username&quot;</span> /&gt;&lt;/td&gt;&lt;/tr&gt;
<a name="l00047"></a>00047                &lt;tr&gt;&lt;td align=<span class="stringliteral">&quot;right&quot;</span>&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type=<span class="stringliteral">&quot;password&quot;</span> name=<span class="stringliteral">&quot;pw&quot;</span> /&gt;&lt;/td&gt;&lt;/tr&gt;
<a name="l00048"></a>00048                &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=<span class="stringliteral">&quot;submit&quot;</span> value=<span class="stringliteral">&quot;Login&quot;</span> name=<span class="stringliteral">&quot;login&quot;</span> /&gt;&lt;/td&gt;&lt;/tr&gt;
<a name="l00049"></a>00049             &lt;/table&gt;
<a name="l00050"></a>00050          &lt;/div&gt;
<a name="l00051"></a>00051       &lt;/form&gt;
<a name="l00052"></a>00052    &lt;/body&gt;
<a name="l00053"></a>00053 &lt;/html&gt;
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 &lt;?php
<a name="l00056"></a>00056 
<a name="l00057"></a><a class="code" href="index_8php.html#a74b79a6d5481c21eb854bced198efc64">00057</a> <span class="keyword">function</span> <a class="code" href="index_8php.html#a74b79a6d5481c21eb854bced198efc64">forwardToURL</a>($per){
<a name="l00058"></a>00058    <span class="keywordflow">switch</span>($per){
<a name="l00059"></a>00059       <span class="keywordflow">case</span> 1: <span class="comment">//student</span>
<a name="l00060"></a>00060          header(<span class="stringliteral">&#39;Location: &#39;</span> . <span class="stringliteral">&#39;view_internships.php&#39;</span>);
<a name="l00061"></a>00061          <span class="keywordflow">break</span>;
<a name="l00062"></a>00062       <span class="keywordflow">case</span> 2: <span class="comment">//assistant</span>
<a name="l00063"></a>00063          header(<span class="stringliteral">&#39;Location: &#39;</span> . <span class="stringliteral">&#39;admin/&#39;</span>);
<a name="l00064"></a>00064          <span class="keywordflow">break</span>;
<a name="l00065"></a>00065       <span class="keywordflow">case</span> 3: <span class="comment">//administrator</span>
<a name="l00066"></a>00066          header(<span class="stringliteral">&#39;Location: &#39;</span> . <span class="stringliteral">&#39;admin/&#39;</span>);
<a name="l00067"></a>00067          <span class="keywordflow">break</span>;
<a name="l00068"></a>00068    }
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00071"></a><a class="code" href="index_8php.html#a61961bfa06c5bf6f45ee402d0696417d">00071</a> <span class="keyword">function</span> <a class="code" href="index_8php.html#a61961bfa06c5bf6f45ee402d0696417d">checkUsernamePassword</a>() {
<a name="l00072"></a>00072    <a class="code" href="db-control_2inc_2db_info_8php.html#a0eb82aa5f81cf845de4b36cd653c42cf">$username</a> = $_POST[<span class="stringliteral">&#39;username&#39;</span>];
<a name="l00073"></a>00073    $pw = $_POST[<span class="stringliteral">&#39;pw&#39;</span>];
<a name="l00074"></a>00074    <span class="keywordflow">if</span> (<a class="code" href="db-control_2inc_2db_info_8php.html#a0eb82aa5f81cf845de4b36cd653c42cf">$username</a> == <span class="stringliteral">&#39;&#39;</span> || $pw == <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00075"></a>00075       <a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a> = <span class="stringliteral">&#39;Please enter a username and password...&#39;</span>;
<a name="l00076"></a>00076    } <span class="keywordflow">else</span> {
<a name="l00077"></a>00077       <a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a> = <span class="keyword">false</span>;
<a name="l00078"></a>00078    }
<a name="l00079"></a>00079    <span class="keywordflow">return</span> <a class="code" href="index_8php.html#aeba2ab722cedda53dbb7ec1a59f45550">$error</a>;
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081 ?&gt;
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Tue Nov 29 2011 18:18:54 for i2c by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
